﻿using Model;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Utility;

namespace DAL
{
    public class UserLoginDAL
    {
        public TY_PersonInfo Login(string UserName, string pwdMd5)
        {
            try
            {
                using (SqlConnection con = new SqlConnection(SqlHelper.MainConnectionString))
                {
                    DataBase db = new DataBase(con);
                    TY_PersonInfo user = (from u in db.TY_PersonInfo
                                          where u.DengLuMing == UserName && u.MiMa == pwdMd5
                                       select u).FirstOrDefault();
                    if (user == null)
                    {
                        return null;
                    }
                    else
                    {
                        return user;
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtility.Error("UserLoginDAL/Login", ex.Message);
                return null;
            }
        }
    }
}
